'use strict';
module.exports =  async({collection,params,token,uniID})=>{
	let res = {}
	let payload = await uniID.checkToken(token)
	if(payload.code == 0){
		let id = params._id
		delete params._id
		if(params.oldPassword && params.newPassword && params.passwordConfirmation){
			let pwd = await uniID.updatePwd({uid:id,oldPassword,newPassword,passwordConfirmation})
			delete params.oldPassword
			delete params.newPassword
			delete params.passwordConfirmation
			if(pwd.code == 0){
				res = await collection.doc(id).update(params)
				res = {...res,code:0,msg:'更新成功'}
			}else{
				res = pwd
			}
		}else{
			delete params.oldPassword
			delete params.newPassword
			delete params.passwordConfirmation
			res = await collection.doc(id).update(params)
			res = {...res,code:0,msg:'更新成功'}
		}
		
	}else{
		res = payload
	}
	//返回数据给客户端
	return res
}